home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bat.zip / BATDEMO.BAT < prev    next >
DOS Batch File  |  1984-11-11  |  10KB  |  257 lines

  1. bat * Begin Batch Language Demo * (C)opyright by Seaware Corp. 1982, 1983
  2. bat *                             (C)opyright by Frank Canova  1982, 1983
  3.  
  4. bat * Send contributions to: Seaware Corp.
  5. bat *                        P.O. Box 1656
  6. bat *                        Delray Beach, FL 33444
  7.  
  8. bat *---- FEATURES OF THE LANGUAGE USED WITHIN THIS DEMO ARE: ----------------
  9. bat * Standary DOS commands can be intermixed freely with BAT commands.
  10. bat * Like basic, putting things at top is quicker for goto's / loops to find.
  11. bat * Up to 15 chars are allowed for labels, contents of vars, and literals
  12. bat * 10 variables are provided to be passed to/from DOS. They're %0 to %9.
  13. bat * 15 variables are provided for user use only. They're %A to %O.
  14. bat * The variable %R is a return code that any routine can set at [0:04FE]
  15. bat * Note that 'BEGTYPE' & 'BEGSTACK' do not do variable substitution.
  16. bat * BEGTYPE  command can have screen attributes via a '\hex' format.
  17. bat * BEGSTACK command can have timing attributes via a '\hex' format.
  18. bat * Spaces are needed to delimit operators.
  19. bat * Non-spaces will concatenate variables and literals.
  20. bat * STATEOF sets return code based on state of files existance.
  21.  
  22. bat cls begtype
  23. ╔════════════════════════════════════════════════════════════════════════╗
  24. ║             (C)opyright by Seaware Corp. 1982, 1983                    ║
  25. ║             (C)opyright by Frank Canova  1982, 1983                    ║
  26. ║                                                                        ║
  27. ║  This is User Supported Software ::                                    ║
  28. ║                                                                        ║
  29. ║  You  are encouraged to  copy and share this program with other users, ║
  30. ║  on the  conditions that the program is not  distributed  in  modified ║
  31. ║  form, that no fee or consideration is charged, and that this notice   ║
  32. ║  is not bypassed or removed.                                           ║
  33. ║                                                                        ║
  34. ║  PRIVATE USERS, If you are using this program and finding it of value, ║
  35. ║          your contribution ($30 suggested) will be appreciated.        ║
  36. ║                                                                        ║
  37. ║  The $30 license fee (per system) is required for COMMERCIAL USERS if  ║
  38. ║          used in a place of business or put into another product.      ║
  39. ║                                                                        ║
  40. ║                    Seaware Corp.                                       ║
  41. ║                    P.O. Box 1656                                       ║
  42. ║                    Delray Beach, FL 33444                              ║
  43. ║                                                                        ║
  44. ╚════════════════════════════════════════════════════════════════════════╝
  45.  
  46. End
  47. bat type What is your first name? ==> ;
  48. bat read %8
  49. bat %7 = 27
  50. bat %L =
  51. bat goto -top
  52.  
  53. bat * number guessing demo *
  54. bat -i.can.count %6 = 5
  55.    bat cls type i am thinking of a two digit number, can you guess it?
  56.    bat -c.loop read %5
  57.    bat if %5 = %7 skip 7
  58.    bat %6 = %6 - 1
  59.    bat if %6 <> 0 skip 2
  60.        bat type boo hisss! the number was %7!
  61.        bat skip 4
  62.    bat if %5 > %7 type try a little lower. you only get %6 more tries.
  63.    bat if %5 < %7 type try a higher number. you get %6 more tries.
  64.    bat goto -c.loop
  65.    bat type great! i was afraid you weren't going to get it!
  66.    bat begtype
  67.  
  68. A BAT program can create loops and count events. With this you can
  69. sequence through file numbers, or create loops to do retrys in case of
  70. errors. In addition, BAT programs can do simple arithmetic and string
  71. manipulation.
  72.  
  73. (press any key to continue)
  74. end
  75. bat inkey
  76.  
  77. bat -top cls type ======== %8's extended batch sampler menu ===========
  78. bat begtype
  79.  
  80.       \0FC\07 - I can Count
  81.  
  82.       \0fD\07 - Directory of available programs
  83.  
  84.       \0fF\07 - Testing for files
  85.  
  86.       \0fK\07 - Keyboard stack (the invisible fingers)
  87.  
  88.       \0fS\07 - Display Screen and String operations
  89.  
  90.       \0fX\07 - Exit
  91.  
  92.  
  93. Select an option.
  94. end
  95. bat -entry read %9
  96. bat %7 = %7 + 3
  97. bat * Skiping is quicker than goto's, but only goes forward.
  98. bat if %9 <> d goto -not.d
  99.     bat type enter file.spec for files you would like to see, or press ENTER for all.
  100.     bat read %1
  101.     bat if .%1 = . %1 = *.*
  102.     bat -dirques type Would you like a (S)tandard or (W)ide directory?
  103.     bat inkey %2 | %m = %2 # | if %m = 1 type %2
  104.     bat * Notice you can chain togeather if's, like . . .
  105.     bat if %2 <> s if %2 <> w goto -dirques
  106.     bat %3 =
  107.     bat if %2 = w %3 = /w
  108.     bat cls
  109.     dir %1 %3  (notice that two parms are passed to dos here. %%1 and %%3)
  110.     bat * Returning to Extended Batch demo *
  111.     bat begtype
  112.  
  113. This directory was created by using a DOS command within this batch file. Any
  114. DOS command can be mixed freely within lines of the BAT program. By passing
  115. parameters to/from DOS, you can have complete control of how a program
  116. operates. User programs may also set a return code in order to control the
  117. execution of the BAT batch file program.
  118.  
  119.     Press any key to continue. . .
  120. end
  121.     bat inkey
  122.     bat goto -top
  123.  
  124. bat -not.d if %9 <> x skip 3
  125.     bat type so long %8....
  126.     bat type p.s. for quickie help, just enter 'bat' from dos.
  127.     bat exit
  128.  
  129. bat if %9 = c goto -i.can.count
  130.  
  131. bat if %9 <> f goto -not.f
  132.     bat type enter a file name for me to search for.
  133.     bat read %9
  134.     bat type scanning for file: %9 . . .
  135.     bat stateof %9 * this will set the return code up (%R)
  136.     bat if %r <> 0 skip 2
  137.     bat    type the file does exist - exactly as typed.
  138.     bat    skip 7
  139.     bat if %r <> 1 skip 2
  140.     bat    type the file does not exist on any drive.
  141.     bat    skip 5
  142.     bat if %r <> 9 skip 2
  143.     bat    type the file name given is invalid.
  144.     bat    skip 2
  145.     bat type the file does exist - but was found on the %r drive.
  146.     bat type to properly find this file, the complete filename would be %9
  147.     bat begtype
  148.  
  149.        File searching is done by a command called STATEOF.
  150.  
  151. If the file was there, we could direct a program to use it, even if it wasn't
  152. on the specific diskette drive that the operator was expecting.
  153.  
  154. If the file was not there, we could have printed out an error message to the
  155. operator, or we could have run an alternate program in order to create the
  156. missing file.
  157.  
  158. Press any key to continue . . .
  159. end
  160.     bat inkey
  161.     bat goto -top
  162.  
  163. bat -not.f if %9 <> k goto -not.k
  164.     bat cls begtype
  165. ╔═════════════════════════════════════════════════════════════════════════════╗
  166. ║                                                                             ║
  167. ║       The keyboard stack can answer questions to programs automatically.    ║
  168. ║       For example, this DOS command can be responded to from the stack.     ║
  169. ║                                                                             ║
  170. ╚═════════════════════════════════════════════════════════════════════════════╝
  171. end
  172.     bat begstack
  173. This text is actually being typed for you from the keyboard stack.
  174. All keys, including control keys and function keys can come from this stack.
  175. Keystrokes can \ff\10even \ff\10have \ff\10delayed \ff\10typing.
  176. \1a
  177. end
  178. rem ... Below is the DOS command that will read the keyboard stack.
  179. copy con: nul:
  180. bat *returning from DOS command*
  181. bat begtype
  182.  
  183. (press any key to continue)
  184. end
  185. bat inkey
  186. bat goto -top
  187.  
  188. bat -not.k if %9 <> s goto -not.s
  189.     bat cls begtype
  190. ╔═════════════════════════════════════════════════════════════════════════════╗
  191. ║                                                                             ║
  192. ║       All sorts of screen attributes can be printed on the screen.          ║
  193. ║                                                                             ║
  194. ║   On monochrome display you see:            On color display you see:       ║
  195. ╚═════════════════════════════════════════════════════════════════════════════╝
  196.  
  197.         \04Normal                               Red on Black  \07
  198.         \0fHigh